import { _decorator, Component, Graphics, Color, UITransform, Layers } from 'cc';

const { ccclass } = _decorator;

@ccclass('PlayerAvatar')
export class PlayerAvatar extends Component {
  onLoad() {
    // Ensure layer and UI anchor
    this.node.layer = Layers.Enum.DEFAULT;
    const ui = this.node.getComponent(UITransform) ?? this.node.addComponent(UITransform);
    ui.setAnchorPoint(0.5, 0.5);
    ui.setContentSize(14, 14);

    const g = this.node.getComponent(Graphics) ?? this.node.addComponent(Graphics);
    g.clear();
    g.fillColor = Color.GREEN;
    g.circle(0, 0, 7);
    g.fill();
  }
}

export default PlayerAvatar;
